﻿#------------------------------------------------------------------------
# Source File Information (DO NOT MODIFY)
# Source ID: 7fd2e565-d22d-4500-936a-778502e603f1
# Source File: SecurityGroupMirrorTool.pfproj
#------------------------------------------------------------------------
#region Project Recovery Data (DO NOT MODIFY)
<#RecoveryData:
WQYAAB+LCAAAAAAABACNVU2PmzAQvVfqf0CoVwJLmqSVCFJL2iiHtKsQ9bRS5MJ4162x0WB2l39f
Ez7CZ7Xi4nnzZjx+4zHeCSL5DFjsiCL++3eG4d2j/AORuhra/AWYMSn8O89ulrXnO+Nw2PkbGruw
Wq+s2HVj6+PKcazPyzWxNptPK8eFtbOkOrYm16GhzDGCQAqFktfgEG7qMD/YYYQsVZkdQpQjU8Ue
ZZ4eGaLEs5Tc9OzJyNm8zywG9ENJ1QtBeDiyCGWmrYeKGBIK45RVUH0Ae+oEjXTnIgXf8eyu2dEs
uxVWmsYJKCCICH6QBLamaXzNGY+3pmP6oSKo8nSR0qyS8P+hAeHc2nP5m/BLmt11MhmBTBIi4m+v
CkTZxK15xhxMv2JnC01/8w761JRhckkp7RZbw7pY+uZUMx0dpp6hjbaqjErgVv/6WpPoL3m8dXAP
ApB0Ll9NKIub2+/yunR12g5xGH2I2vm4VjCFHolgFDIVIBBVj9YIa9lBnimZNP5O7jnHPSeKSkzK
tO269Z5yEZ6/lL56dYuTL4DhE3DezPlSJxiBjdB9/bxGMcMePhy9S9C+Jgun/Kp+jZi6cXEeqRF5
gA/5/Y7Yk+gOsutj0ou3J1E9MikRRVfyIRLItED2+NTryxg7CAUoCB8UOA3/1MFMo6Uyg4B5Vzne
IPpldJH+491ezGoaxlvOz1uqZ2qyEH2hur+Sf/DzahNZBgAA#>
#endregion
#========================================================================
# Code Generated By: SAPIEN Technologies, Inc., PowerShell Studio 2012 v3.1.26
# Generated On: 11/14/2013 10:11 AM
# Generated By: jheaton
#========================================================================


#region Source: Startup.pfs
#region File Recovery Data (DO NOT MODIFY)
<#RecoveryData:
CwcAAB+LCAAAAAAABAC9Vdtu2zAMfR+wf/AHZJY9x0kLqAYCBx2KYVtQF9teFYVOhcqSoUsD//2U
zNfY6YY+BH4xDy+HokQSPwKVr6CqNTEk+fjB8/APxfZMEH7POHwnBSSZIcrY0i9zjdFIe/I5Sj9B
aSZFEvqfMeoDJ4uV1lBsOQN9kjukSrJKGyj8b0SQPRQgjL+yRhbEOOeZV0e5i/zg+M281HJjFdwJ
sEYRPvM21sWlX6F6ki/gDMNtHt3EC7KLFnOIYoxapmnmjmP+vxzb5ZLENF6Et9Ecgpvbf3L4v5jY
yYP276Uq9FUY14ocmNi/hyuI8jhf5mG4iwMSkTe4Ck2l4mx7nRO5N3oVot8Fv86BmAJqpKoyUK+M
wrsextuX1YpN5+ENoS+u0VST1BcQ4ALXYmfQdvcJRJNoDT7Qus0HpkPUtTfLQZtUwamzkxCjEdZa
p1a7EdDoe7EvKTacmNz1VvLJxW2FVv1oRfa0SgKM6r/OUR5AZc/AeTOv3Pgag3Wx0LBaOANqFTOV
hxpk6HA2G7tzTKIbJXeWmrH1JUWNn1/VFLoGTRUrh2VGk2gqi5KIql/1cySVZeU2wfPgasbYgzCg
3LY4S3Aanlwtfx0uq1xmx5UxzLWHYDRYQ6j3+t1b6C+/P5RBcLgLBwAA#>
#endregion
#----------------------------------------------
#region Import Assemblies
#----------------------------------------------
[void][Reflection.Assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
[void][Reflection.Assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
[void][Reflection.Assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
[void][Reflection.Assembly]::Load("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
[void][Reflection.Assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
[void][Reflection.Assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
[void][Reflection.Assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
#endregion Import Assemblies

#Define a Param block to use custom parameters in the project
#Param ($CustomParameter)

function Main {
	Param ([String]$Commandline)
	#Note: This function starts the application
	#Note: $Commandline contains the complete argument string passed to the packager
	#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
	#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
	#TODO: Initialize and add Function calls to forms
	
	if((Call-SecurityGroupMirrorTool_pff) -eq "OK")
	{
		
	}
	
	$global:ExitCode = 0 #Set the exit code for the Packager
}







#endregion Source: Startup.pfs

#region Source: Globals.ps1
	#--------------------------------------------
	# Declare Global Variables and Functions here
	#--------------------------------------------
	
	#Sample function that provides the location of the script
	function Get-ScriptDirectory
	{ 
		if($hostinvocation -ne $null)
		{
			Split-Path $hostinvocation.MyCommand.path
		}
		else
		{
			Split-Path $script:MyInvocation.MyCommand.Path
		}
	}
	
	#Sample variable that provides the location of the script
	[string]$ScriptDirectory = Get-ScriptDirectory
#endregion Source: Globals.ps1

#region Source: Confirm.pff
function Call-Confirm_pff
{
#region File Recovery Data (DO NOT MODIFY)
<#RecoveryData:
WxEAAB+LCAAAAAAABADNmP9v2joQwH+f9P6HKD8jQkhTWgkitenrU7VuQ8Dr3m+TcS7gN8dGttM2
++vnfIOEhBHYVk2VKnK+853tz51zGc8A82cQyR1SyPvrnWGMPwmyIgzRe0LhI4rA8zkLiYj6mzAc
W43RzCZ9egIhCWee3R+Oraogn3X5P2BlqGQDE3OeSAVR/zNhAX+R/Xsuovx/z2gb6hnFVJOL/iD9
6xl+TFUsYMIgVgLRnjGNl5Tg95As+Fdgk+VohFzsXtrXzgUMrq5Ng+lgJ2ao57vBGDbKXyO2Amka
eE1oILSNqReqBKfSzELWQU8F34BQSWGcG97GSnFW6mitGYSg7TEUastModg107DK2axyukPTx4rP
yTcwvYWI4aj6LcJffU65ML3Pa6KOG/hIx0i7hp8pnxC9TwkwlcfvDN2e4biDo0YpQabXOJSjdnOF
hJpySRRJ1+JrzyCmSC9DHbVdwKsyvdyfcdDh3896rsLikaPA9FIUM+mX9HlsZb9L9eN4zwhep65v
+etvp1yo5Ra/w3i3EMjwOuVpwTc945ZrDnRGPkKoesaMrNbNvT2DyhYTLgIQc5VQzcJHzrrYPHKM
8rO3hz3DHnYwyVnbbU0Hk4LmgT6K4fWog8ECLR9YAK+m1yWinMTtaINBK6eqO2N5bv92vOoV4hzA
Sra6UuWjWIJ8QpQExbHfIyq7gHJHEOWrGUi9Vl0osphP4mvoXOlaZrudCavuTmfGRrpgDp2TCLM7
E9Y5ln8lPBEZI5olYyWV2y+kP5zPn6mApwJax+zT+9NKmDs6C7ET69gZjDVv8IOMdQ7mJyCrP9xI
CZEGAmSpW0gSrwDsA2JoBZG+p/vpy1WU7fcONKcraI69DJ0r9xIFzuUFOPqgtp7aPf8CmI/6+OXp
c9zjnUAvhK3O8TVwQjcchbYduAPkoB/4iiTmgpLl26xItz1v4ui/iL7NgojQCcJFMgfxTDCcBcaP
D2v7WGbeeKqTWCeaKIP6BxjoiSslIFfYNozF+06btBA+4KJzrKnWpTq9SQhS+QKyzE6vxIZsq+3H
UpeAcrwy96GBKUUqbU28tGaWv3dtU8zmi5u0Qha/dnb8Rb/OroHSsgNOXwYbwrK+1TdrPAccC6Kr
5bbzqhs0uu3sUJsdd1l6gxirhvKefF9//5zapHcgsSCb+h5brVKfRxvEkuqW70t8vklEetfWlBqy
h7TPY4juBdgubv1UUdwpB4d0ZNGurytirUjGVu2zhlVBX5NQ/ZjyHWkNha5bEQAA#>
#endregion
Param(
	[string]$User1,
	[string]$User2,
	[string[]]$Array1,
	[string[]]$Array2
)

	#----------------------------------------------
	#region Import the Assemblies
	#----------------------------------------------
	[void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	#endregion Import Assemblies

	#----------------------------------------------
	#region Generated Form Objects
	#----------------------------------------------
	[System.Windows.Forms.Application]::EnableVisualStyles()
	$formAcceptChanges = New-Object 'System.Windows.Forms.Form'
	$rtbConfirm = New-Object 'System.Windows.Forms.RichTextBox'
	$buttonCancel = New-Object 'System.Windows.Forms.Button'
	$buttonConfirm = New-Object 'System.Windows.Forms.Button'
	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
	#endregion Generated Form Objects

	#----------------------------------------------
	# User Generated Script
	#----------------------------------------------
	
	$FormEvent_Load={
		$U1 = Get-ADUser $User1 -Properties displayName
		$U2 = Get-ADUser $User2 -Properties displayName
		if($Array1 -ne $null){
			$t1 = ("Adding " + $U1.displayName + " to the following groups:")
			Append-RTB -RichTextBox $rtbConfirm -Text ($t1 + "`n") -Color 'Firebrick'
			Append-RTB -RichTextBox $rtbConfirm -Text ($Array1 | Out-String)
			Append-RTB -RichTextBox $rtbConfirm -Text ("`n")
		}
		if($Array2 -ne $null){
			$t2 = ("Adding " + $U2.displayName + " to the following groups:")
			Append-RTB -RichTextBox $rtbConfirm -Text ($t2 + "`n") -Color 'Firebrick'
			Append-RTB -RichTextBox $rtbConfirm -Text ($Array2 | Out-String)
		}
	}
	
	function Append-RTB{
		Param(
			[System.Windows.Forms.RichTextBox]$RichTextBox,
			[string]$Text,
			[System.Drawing.Color]$Color
			
		)
		$FontHeader = new-object System.Drawing.Font("Microsoft Sans Serif",8,[System.Drawing.FontStyle]'Regular')	
		$FontNormal = new-object System.Drawing.Font("Microsoft Sans Serif",8,[System.Drawing.FontStyle]'Regular')	
		if($Color){
			$RichTextBox.SelectionFont = $FontHeader
			$RichTextBox.SelectionColor = $Color
			$RichTextBox.AppendText($Text)
		}
		else{
			$RichTextBox.SelectionFont = $FontNormal
			$RichTextBox.SelectionColor = 'Black'
			$RichTextBox.AppendText($Text)
		}
	}
	
	# --End User Generated Script--
	#----------------------------------------------
	#region Generated Events
	#----------------------------------------------
	
	$Form_StateCorrection_Load=
	{
		#Correct the initial state of the form to prevent the .Net maximized form issue
		$formAcceptChanges.WindowState = $InitialFormWindowState
	}
	
	$Form_StoreValues_Closing=
	{
		#Store the control values
		$script:Confirm_rtbConfirm = $rtbConfirm.Text
	}

	
	$Form_Cleanup_FormClosed=
	{
		#Remove all event handlers from the controls
		try
		{
			$formAcceptChanges.remove_Load($FormEvent_Load)
			$formAcceptChanges.remove_Load($Form_StateCorrection_Load)
			$formAcceptChanges.remove_Closing($Form_StoreValues_Closing)
			$formAcceptChanges.remove_FormClosed($Form_Cleanup_FormClosed)
		}
		catch [Exception]
		{ }
	}
	#endregion Generated Events

	#----------------------------------------------
	#region Generated Form Code
	#----------------------------------------------
	#
	# formAcceptChanges
	#
	$formAcceptChanges.Controls.Add($rtbConfirm)
	$formAcceptChanges.Controls.Add($buttonCancel)
	$formAcceptChanges.Controls.Add($buttonConfirm)
	$formAcceptChanges.AcceptButton = $buttonConfirm
	$formAcceptChanges.AutoSize = $True
	$formAcceptChanges.BackColor = 'White'
	$formAcceptChanges.CancelButton = $buttonCancel
	$formAcceptChanges.ClientSize = '325, 350'
	$formAcceptChanges.Name = "formAcceptChanges"
	$formAcceptChanges.StartPosition = 'CenterParent'
	$formAcceptChanges.Text = "Accept Changes"
	$formAcceptChanges.add_Load($FormEvent_Load)
	#
	# rtbConfirm
	#
	$rtbConfirm.Anchor = 'Top, Bottom, Left, Right'
	$rtbConfirm.BackColor = 'White'
	$rtbConfirm.BorderStyle = 'None'
	$rtbConfirm.Location = '12, 12'
	$rtbConfirm.Name = "rtbConfirm"
	$rtbConfirm.Size = '300, 297'
	$rtbConfirm.TabIndex = 2
	$rtbConfirm.Text = ""
	#
	# buttonCancel
	#
	$buttonCancel.Anchor = 'Bottom, Right'
	$buttonCancel.CausesValidation = $False
	$buttonCancel.DialogResult = 'Cancel'
	$buttonCancel.Location = '238, 315'
	$buttonCancel.Name = "buttonCancel"
	$buttonCancel.Size = '75, 23'
	$buttonCancel.TabIndex = 1
	$buttonCancel.Text = "Cancel"
	$buttonCancel.UseVisualStyleBackColor = $True
	#
	# buttonConfirm
	#
	$buttonConfirm.Anchor = 'Bottom, Right'
	$buttonConfirm.DialogResult = 'OK'
	$buttonConfirm.Location = '157, 315'
	$buttonConfirm.Name = "buttonConfirm"
	$buttonConfirm.Size = '75, 23'
	$buttonConfirm.TabIndex = 0
	$buttonConfirm.Text = "Confirm"
	$buttonConfirm.UseVisualStyleBackColor = $True
	#endregion Generated Form Code

	#----------------------------------------------

	#Save the initial state of the form
	$InitialFormWindowState = $formAcceptChanges.WindowState
	#Init the OnLoad event to correct the initial state of the form
	$formAcceptChanges.add_Load($Form_StateCorrection_Load)
	#Clean up the control events
	$formAcceptChanges.add_FormClosed($Form_Cleanup_FormClosed)
	#Store the control values when form is closing
	$formAcceptChanges.add_Closing($Form_StoreValues_Closing)
	#Show the Form
	return $formAcceptChanges.ShowDialog()

}
#endregion Source: Confirm.pff

#region Source: SecurityGroupMirrorTool.pff
function Call-SecurityGroupMirrorTool_pff
{
#region File Recovery Data (DO NOT MODIFY)
<#RecoveryData:
tWUAAB+LCAAAAAAABADtXV13ojoXvj9rnf/A8uJceaqAtPU91rVQp/bDOq0f2HozCzAqbQAXBCvz
698E/BYw0J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lULeEGMnBTaKVvWrjo2jnaL62tth124hzIib1LwDiAtfl9ebTlG
uyOSa/PfVnLmK7DaYwDh4l0aZEW2U7hY/Wz6rrR8rv5i47q0KcBsv7fDG+Pdd3cs7iEDR0U7lbfK
t+tvjkgusHTx8K8N+Vxgqbeja7jrLt8uqZoT1yJr8I1KO2XXBgKWIcMtBYOLA1964guEX8KabTzz
zNN1raSU23hBSm5tJmAkrL+m5f+GTx6dtWUAAA==#>
#endregion
	#----------------------------------------------
	#region Import the Assemblies
	#----------------------------------------------
	[void][reflection.assembly]::Load("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	#endregion Import Assemblies

	#----------------------------------------------
	#region Generated Form Objects
	#----------------------------------------------
	[System.Windows.Forms.Application]::EnableVisualStyles()
	$formSecurityGroupMirrorT = New-Object 'System.Windows.Forms.Form'
	$GBSecGroup = New-Object 'System.Windows.Forms.GroupBox'
	$tlp1 = New-Object 'System.Windows.Forms.TableLayoutPanel'
	$panel1 = New-Object 'System.Windows.Forms.Panel'
	$btnApply = New-Object 'System.Windows.Forms.Button'
	$btnMerge = New-Object 'System.Windows.Forms.Button'
	$btnU1toU2 = New-Object 'System.Windows.Forms.Button'
	$btnU2toU1 = New-Object 'System.Windows.Forms.Button'
	$GBUser2 = New-Object 'System.Windows.Forms.GroupBox'
	$lblU2 = New-Object 'System.Windows.Forms.Label'
	$btnClearU2 = New-Object 'System.Windows.Forms.Button'
	$LVU2 = New-Object 'System.Windows.Forms.ListView'
	$btnSelectAllU2 = New-Object 'System.Windows.Forms.Button'
	$btnGetU2 = New-Object 'System.Windows.Forms.Button'
	$txtbxSAM2 = New-Object 'System.Windows.Forms.TextBox'
	$lblU2ADLogon = New-Object 'System.Windows.Forms.Label'
	$GBUser1 = New-Object 'System.Windows.Forms.GroupBox'
	$lblU1 = New-Object 'System.Windows.Forms.Label'
	$LVU1 = New-Object 'System.Windows.Forms.ListView'
	$btnClearU1 = New-Object 'System.Windows.Forms.Button'
	$btnSelectAllU1 = New-Object 'System.Windows.Forms.Button'
	$btnGetU1 = New-Object 'System.Windows.Forms.Button'
	$txtbxSAM1 = New-Object 'System.Windows.Forms.TextBox'
	$lblU1ADLogon = New-Object 'System.Windows.Forms.Label'
	$btnClose = New-Object 'System.Windows.Forms.Button'
	$LV1GroupName = New-Object 'System.Windows.Forms.ColumnHeader'
	$Name = New-Object 'System.Windows.Forms.ColumnHeader'
	$LV1Type = New-Object 'System.Windows.Forms.ColumnHeader'
	$LV1DN = New-Object 'System.Windows.Forms.ColumnHeader'
	$LV2GroupName = New-Object 'System.Windows.Forms.ColumnHeader'
	$LV2Type = New-Object 'System.Windows.Forms.ColumnHeader'
	$LV2DN = New-Object 'System.Windows.Forms.ColumnHeader'
	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
	#endregion Generated Form Objects

	#----------------------------------------------
	# User Generated Script
	#----------------------------------------------
	Import-Module ActiveDirectory
	$formSecurityGroupMirrorT_Load={
		#TODO: Initialize Form Controls here
		
	}
	#region Control Helper Functions
	function Sort-ListViewColumn 
	{
		<#
		.SYNOPSIS
			Sort the ListView's item using the specified column.
	
		.DESCRIPTION
			Sort the ListView's item using the specified column.
			This function uses Add-Type to define a class that sort the items.
			The ListView's Tag property is used to keep track of the sorting.
	
		.PARAMETER ListView
			The ListView control to sort.
	
		.PARAMETER ColumnIndex
			The index of the column to use for sorting.
			
		.PARAMETER  SortOrder
			The direction to sort the items. If not specified or set to None, it will toggle.
		
		.EXAMPLE
			Sort-ListViewColumn -ListView $listview1 -ColumnIndex 0
	#>
		param(	
				[ValidateNotNull()]
				[Parameter(Mandatory=$true)]
				[System.Windows.Forms.ListView]$ListView,
				[Parameter(Mandatory=$true)]
				[int]$ColumnIndex,
				[System.Windows.Forms.SortOrder]$SortOrder = 'None')
		
		if(($ListView.Items.Count -eq 0) -or ($ColumnIndex -lt 0) -or ($ColumnIndex -ge $ListView.Columns.Count))
		{
			return;
		}
		
		#region Define ListViewItemComparer
			try{
			$local:type = [ListViewItemComparer]
		}
		catch{
		Add-Type -ReferencedAssemblies ('System.Windows.Forms') -TypeDefinition  @" 
	using System;
	using System.Windows.Forms;
	using System.Collections;
	public class ListViewItemComparer : IComparer
	{
	    public int column;
	    public SortOrder sortOrder;
	    public ListViewItemComparer()
	    {
	        column = 0;
			sortOrder = SortOrder.Ascending;
	    }
	    public ListViewItemComparer(int column, SortOrder sort)
	    {
	        this.column = column;
			sortOrder = sort;
	    }
	    public int Compare(object x, object y)
	    {
			if(column >= ((ListViewItem)x).SubItems.Count)
				return  sortOrder == SortOrder.Ascending ? -1 : 1;
		
			if(column >= ((ListViewItem)y).SubItems.Count)
				return sortOrder == SortOrder.Ascending ? 1 : -1;
		
			if(sortOrder == SortOrder.Ascending)
	        	return String.Compare(((ListViewItem)x).SubItems[column].Text, ((ListViewItem)y).SubItems[column].Text);
			else
				return String.Compare(((ListViewItem)y).SubItems[column].Text, ((ListViewItem)x).SubItems[column].Text);
	    }
	}
"@  | Out-Null
		}
		#endregion
		
		if($ListView.Tag -is [ListViewItemComparer])
		{
			#Toggle the Sort Order
			if($SortOrder -eq [System.Windows.Forms.SortOrder]::None)
			{
				if($ListView.Tag.column -eq $ColumnIndex -and $ListView.Tag.sortOrder -eq 'Ascending')
				{
					$ListView.Tag.sortOrder = 'Descending'
				}
				else
				{
					$ListView.Tag.sortOrder = 'Ascending'
				}
			}
			else
			{
				$ListView.Tag.sortOrder = $SortOrder
			}
			
			$ListView.Tag.column = $ColumnIndex
			$ListView.Sort()#Sort the items
		}
		else
		{
			if($Sort -eq [System.Windows.Forms.SortOrder]::None)
			{
				$Sort = [System.Windows.Forms.SortOrder]::Ascending	
			}
			
			#Set to Tag because for some reason in PowerShell ListViewItemSorter prop returns null
			$ListView.Tag = New-Object ListViewItemComparer ($ColumnIndex, $SortOrder) 
			$ListView.ListViewItemSorter = $ListView.Tag #Automatically sorts
		}
	}
	
	
	function Add-ListViewItem
	{
	<#
		.SYNOPSIS
			Adds the item(s) to the ListView and stores the object in the ListViewItem's Tag property.
	
		.DESCRIPTION
			Adds the item(s) to the ListView and stores the object in the ListViewItem's Tag property.
	
		.PARAMETER ListView
			The ListView control to add the items to.
	
		.PARAMETER Items
			The object or objects you wish to load into the ListView's Items collection.
			
		.PARAMETER  ImageIndex
			The index of a predefined image in the ListView's ImageList.
		
		.PARAMETER  SubItems
			List of strings to add as Subitems.
		
		.PARAMETER Group
			The group to place the item(s) in.
		
		.PARAMETER Clear
			This switch clears the ListView's Items before adding the new item(s).
		
		.EXAMPLE
			Add-ListViewItem -ListView $listview1 -Items "Test" -Group $listview1.Groups[0] -ImageIndex 0 -SubItems "Installed"
	#>
		
		Param( 
		[ValidateNotNull()]
		[Parameter(Mandatory=$true)]
		[System.Windows.Forms.ListView]$ListView,
		[ValidateNotNull()]
		[Parameter(Mandatory=$true)]
		$Items,
		[int]$ImageIndex = -1,
		[string[]]$SubItems,
		[System.Windows.Forms.ListViewGroup]$Group,
		[switch]$Clear)
		
		if($Clear)
		{
			$ListView.Items.Clear();
		}
		
		if($Items -is [Array])
		{
			$ListView.BeginUpdate()
			foreach ($item in $Items)
			{		
				$listitem  = $ListView.Items.Add($item.ToString(), $ImageIndex)
				#Store the object in the Tag
				$listitem.Tag = $item
				
				if($SubItems -ne $null)
				{
					$listitem.SubItems.AddRange($SubItems)
				}
				
				if($Group -ne $null)
				{
					$listitem.Group = $Group
				}
			}
			$ListView.EndUpdate()
		}
		else
		{
			#Add a new item to the ListView
			$listitem  = $ListView.Items.Add($Items.ToString(), $ImageIndex)
			#Store the object in the Tag
			$listitem.Tag = $Items
			
			if($SubItems -ne $null)
			{
				$listitem.SubItems.AddRange($SubItems)
			}
			
			if($Group -ne $null)
			{
				$listitem.Group = $Group
			}
		}
	}
	
	#endregion
	#region Custom Functions
	function SelectAll-ListViewItems{
		param([System.Windows.Forms.ListView]$LV)
		$LV.Focus()
		foreach($item in $LV.Items){
			$item.Selected = $true	
		}	
	}
	function Insert-ListViewItem{
	<#
		.SYNOPSIS
			Inserts the item(s) to the ListView and stores the object in the ListViewItem's Tag property.
	
		.DESCRIPTION
			Inserts the item(s) to the ListView and stores the object in the ListViewItem's Tag property.
	
		.PARAMETER ListView
			The ListView control to inserts the items to.
	
		.PARAMETER Items
			The object or objects you wish to load into the ListView's Items collection.
			
		.PARAMETER  ImageIndex
			The index of a predefined image in the ListView's ImageList.
		
		.PARAMETER  SubItems
			List of strings to insert as Subitems.
		
		.PARAMETER Group
			The group to place the item(s) in.
		
		.PARAMETER Clear
			This switch clears the ListView's Items before adding the new item(s).
		
		.EXAMPLE
			Insert-ListViewItem -ListView $listview1 -Items "Test" -Group $listview1.Groups[0] -ImageIndex 0 -SubItems "Installed"
	#>
		
		Param( 
		[ValidateNotNull()]
		[Parameter(Mandatory=$true)]
		[System.Windows.Forms.ListView]$ListView,
		[ValidateNotNull()]
		[Parameter(Mandatory=$true)]
		$Items,
		[int]$ImageIndex = -1,
		[string[]]$SubItems,
		[System.Windows.Forms.ListViewGroup]$Group,
		[System.Drawing.Color]$Color,
		[switch]$Clear)
		
		if($Clear)
		{
			$ListView.Items.Clear();
		}
		
		if($Items -is [Array])
		{
			$ListView.BeginUpdate()
			foreach ($item in $Items)
			{
				$listitem  = $ListView.Items.Insert(0,$item.ToString(), $ImageIndex)
				#Add Color if specified
				if($Color -ne $null){
					$listitem.ForeColor = $Color
				}
				#Store the object in the Tag
				$listitem.Tag = $item
				
				if($SubItems -ne $null)
				{
					$listitem.SubItems.AddRange($SubItems)
				}
				
				if($Group -ne $null)
				{
					$listitem.Group = $Group
				}
			}
			$ListView.EndUpdate()
		}
		else
		{
		
			#Insert a new item to the ListView
			$listitem  = $ListView.Items.Insert(0,$Items.ToString(), $ImageIndex)
			#Add Color if specified
			if($Color -ne $null){
				$listitem.ForeColor = $Color
			}
			#Store the object in the Tag
			$listitem.Tag = $Items
			
			if($SubItems -ne $null)
			{
				$listitem.SubItems.AddRange($SubItems)
			}
			
			if($Group -ne $null)
			{
				$listitem.Group = $Group
			}
		}
	}
	function Compare-LVI-SendDiff{
		param(
			[System.Windows.Forms.ListView]$LVRef,
			[System.Windows.Forms.ListView]$LVDiff,
			[System.Drawing.Color]$ForeColor
		)
		
		if($LVDiff.SelectedItems.Count -gt 0){
			$Duplicates = @()
			Compare-Object -ReferenceObject $LVRef.Items -DifferenceObject $LVDiff.SelectedItems -IncludeEqual |
			%{
				if ($_.SideIndicator -eq "=>"){
					$Item = $_.InputObject.Text
					$Subs = @()
					for ($i = 1; $i -lt $_.InputObject.SubItems.Count; $i++){
						$Subs += $_.InputObject.SubItems[$i].Text
					}
					Insert-ListViewItem -ListView $LVRef -Items $Item -SubItems $Subs -Color $ForeColor
				}
				elseif ($_.SideIndicator -eq "=="){
					$Duplicates += $_.InputObject.Text
				}
			}
	#		if($Duplicates -ne $null){
	#			[System.Windows.Forms.MessageBox]::Show("The following items are duplicates and will not be copied over:`n`n" + ($Duplicates | Out-String) + "","Duplicate Items",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Information)
	#		}
		}	
	}
	function Populate-ListView{
		Param(
			[System.Windows.Forms.ListView]$ListView,
			[System.Windows.Forms.TextBox]$TextBox
		)
		$ListView.Items.Clear()
		$u = try{Get-ADUser -Identity $TextBox.Text -Properties memberOf,displayName,Title}catch{[System.Windows.Forms.MessageBox]::Show($_.Exception.Message,"Error",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Error);return "Error"}
		foreach($g in $u.memberof){
			$group = Get-ADGroup -Identity $g
			Add-ListViewItem -ListView $ListView -Items $group.name -SubItems $group.GroupCategory,$group.DistinguishedName
		}
		Sort-ListViewColumn -ListView $ListView -ColumnIndex 0 -SortOrder 'Ascending'
		return $u
	}
	#endregion Custom Functions
	#region Event Handlers
	$LVU1_ColumnClick=[System.Windows.Forms.ColumnClickEventHandler]{
		Sort-ListViewColumn $this $_.Column	
	}
	$LVU2_ColumnClick=[System.Windows.Forms.ColumnClickEventHandler]{
		Sort-ListViewColumn $this $_.Column	
	}
	#endregion Event Handlers
	#region Buttons
	$btnGetU1_Click={
		$u1 = Populate-ListView -ListView $LVU1 -TextBox $txtbxSAM1
		if($u1 -ne "Error"){
			$lblU1.Text = ("Display Name: " + $u1.displayName + "     Title: " + $u1.Title)
		}
	}
	$btnGetU2_Click={
		$u2 = Populate-ListView -ListView $LVU2 -TextBox $txtbxSAM2
		if($u2 -ne "Error"){
			$lblU2.Text = ("Display Name: " + $u2.displayName + "     Title: " + $u2.Title)
		}
	}
	$btnClearU1_Click={
		$LVU1.Items.Clear()
	}
	$btnClearU2_Click={
		$LVU2.Items.Clear()
	}
	$btnU1toU2_Click={
		Compare-LVI-SendDiff -LVRef $LVU2 -LVDiff $LVU1 -ForeColor 'Firebrick'	
	}
	$btnU2toU1_Click={
		Compare-LVI-SendDiff -LVRef $LVU1 -LVDiff $LVU2 -ForeColor 'Firebrick'	
	}
	$btnSelectAllU1_Click={
		SelectAll-ListViewItems -LV $LVU1
	}
	$btnSelectAllU2_Click={
		SelectAll-ListViewItems -LV $LVU2
	}
	$btnMerge_Click={
		SelectAll-ListViewItems -LV $LVU2	
		Compare-LVI-SendDiff -LVRef $LVU1 -LVDiff $LVU2 -ForeColor 'Firebrick'
		SelectAll-ListViewItems -LV $LVU1	
		Compare-LVI-SendDiff -LVRef $LVU2 -LVDiff $LVU1 -ForeColor 'Firebrick'
		$btnMerge.Focus()
	}
	$btnApply_Click={
		#TODO: Place custom script here
		$U1GroupNames=@()
		$U2GroupNames=@()
		$U1GroupDNs=@()
		$U2GroupDNs=@()
		foreach($item in $LVU1.Items | where {$_.Forecolor -NE 'WindowText'}){
			$U1GroupNames += $item.Text
			$U1GroupDNs += $item.subItems[2].Text
		}
		foreach($item in $LVU2.Items | where {$_.Forecolor -NE 'WindowText'}){
			$U2GroupNames += $item.Text
			$U2GroupDNs += $item.subItems[2].Text
		}
		if((Call-Confirm_pff -User1 $txtbxSAM1.Text -User2 $txtbxSAM2.Text -Array1 $U1GroupNames -Array2 $U2GroupNames) -eq "OK"){
			if($U1GroupDNs.Count -gt 0){
				$U1GroupDNs | %{ try{ Add-ADGroupMember -Identity $_ -Members $txtbxSAM1.Text }catch{[System.Windows.Forms.MessageBox]::Show($_.Exception.Message,"Error",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Error);return "Error"} }
			}
			if($U2GroupDNs.Count -gt 0){
				$U2GroupDNs | %{ try{ Add-ADGroupMember -Identity $_ -Members $txtbxSAM2.Text }catch{[System.Windows.Forms.MessageBox]::Show($_.Exception.Message,"Error",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Error);return "Error"} }
			}
			[System.Windows.Forms.MessageBox]::Show("Security Groups Updated.","Operation Complete",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Information)		
		}
	}
	#endregion Buttons
	#region Process other Key Presses "Enter", "Esc" ###
	$formSecurityGroupMirrorT.KeyPreview = $True
	$formSecurityGroupMirrorT.Add_KeyDown({
		if($_.KeyCode -eq "Enter"){
			if($txtbxSAM1.get_Focused()){$btnGetU1.PerformClick()}
			elseif($txtbxSAM2.get_Focused()){$btnGetU2.PerformClick()}
		}
	
	})
	$formSecurityGroupMirrorT.Add_KeyDown({
		if($_.KeyCode -eq "Escape"){
			clear	
			$formSecurityGroupMirrorT.Close()
		}
	})
	#endregion Process other Key Presses "Enter", "Esc" ###	# --End User Generated Script--
	#----------------------------------------------
	#region Generated Events
	#----------------------------------------------
	
	$Form_StateCorrection_Load=
	{
		#Correct the initial state of the form to prevent the .Net maximized form issue
		$formSecurityGroupMirrorT.WindowState = $InitialFormWindowState
	}
	
	$Form_StoreValues_Closing=
	{
		#Store the control values
		$script:SecurityGroupMirrorTool_LVU2 = $LVU2.SelectedItems
		$script:SecurityGroupMirrorTool_txtbxSAM2 = $txtbxSAM2.Text
		$script:SecurityGroupMirrorTool_LVU1 = $LVU1.SelectedItems
		$script:SecurityGroupMirrorTool_txtbxSAM1 = $txtbxSAM1.Text
	}

	
	$Form_Cleanup_FormClosed=
	{
		#Remove all event handlers from the controls
		try
		{
			$btnApply.remove_Click($btnApply_Click)
			$btnMerge.remove_Click($btnMerge_Click)
			$btnU1toU2.remove_Click($btnU1toU2_Click)
			$btnU2toU1.remove_Click($btnU2toU1_Click)
			$btnClearU2.remove_Click($btnClearU2_Click)
			$LVU2.remove_ColumnClick($LVU2_ColumnClick)
			$btnSelectAllU2.remove_Click($btnSelectAllU2_Click)
			$btnGetU2.remove_Click($btnGetU2_Click)
			$LVU1.remove_ColumnClick($LVU1_ColumnClick)
			$btnClearU1.remove_Click($btnClearU1_Click)
			$btnSelectAllU1.remove_Click($btnSelectAllU1_Click)
			$btnGetU1.remove_Click($btnGetU1_Click)
			$formSecurityGroupMirrorT.remove_Load($formSecurityGroupMirrorT_Load)
			$formSecurityGroupMirrorT.remove_Load($Form_StateCorrection_Load)
			$formSecurityGroupMirrorT.remove_Closing($Form_StoreValues_Closing)
			$formSecurityGroupMirrorT.remove_FormClosed($Form_Cleanup_FormClosed)
		}
		catch [Exception]
		{ }
	}
	#endregion Generated Events

	#----------------------------------------------
	#region Generated Form Code
	#----------------------------------------------
	#
	# formSecurityGroupMirrorT
	#
	$formSecurityGroupMirrorT.Controls.Add($GBSecGroup)
	$formSecurityGroupMirrorT.Controls.Add($btnClose)
	$formSecurityGroupMirrorT.BackColor = 'Control'
	$formSecurityGroupMirrorT.ClientSize = '1018, 391'
	$formSecurityGroupMirrorT.Name = "formSecurityGroupMirrorT"
	$formSecurityGroupMirrorT.Text = "Security Group Mirror Tool"
	$formSecurityGroupMirrorT.add_Load($formSecurityGroupMirrorT_Load)
	#
	# GBSecGroup
	#
	$GBSecGroup.Controls.Add($tlp1)
	$GBSecGroup.Anchor = 'Top, Bottom, Left, Right'
	$GBSecGroup.BackColor = 'Control'
	$GBSecGroup.Location = '12, 12'
	$GBSecGroup.Name = "GBSecGroup"
	$GBSecGroup.Size = '995, 342'
	$GBSecGroup.TabIndex = 60
	$GBSecGroup.TabStop = $False
	$GBSecGroup.Text = "Security Group Mirror Tool"
	#
	# tlp1
	#
	$tlp1.Controls.Add($panel1, 1, 0)
	$tlp1.Controls.Add($GBUser2, 2, 0)
	$tlp1.Controls.Add($GBUser1, 0, 0)
	$tlp1.BackColor = 'LightSlateGray'
	$tlp1.ColumnCount = 3
	$System_Windows_Forms_ColumnStyle_1 = New-Object 'System.Windows.Forms.ColumnStyle' ('Percent', 50)
	[void]$tlp1.ColumnStyles.Add($System_Windows_Forms_ColumnStyle_1)
	$System_Windows_Forms_ColumnStyle_2 = New-Object 'System.Windows.Forms.ColumnStyle' ('Absolute', 90)
	[void]$tlp1.ColumnStyles.Add($System_Windows_Forms_ColumnStyle_2)
	$System_Windows_Forms_ColumnStyle_3 = New-Object 'System.Windows.Forms.ColumnStyle' ('Percent', 50)
	[void]$tlp1.ColumnStyles.Add($System_Windows_Forms_ColumnStyle_3)
	$tlp1.Dock = 'Fill'
	$tlp1.Location = '3, 16'
	$tlp1.Name = "tlp1"
	$tlp1.RowCount = 1
	$System_Windows_Forms_RowStyle_4 = New-Object 'System.Windows.Forms.RowStyle' ('Percent', 100)
	[void]$tlp1.RowStyles.Add($System_Windows_Forms_RowStyle_4)
	$System_Windows_Forms_RowStyle_5 = New-Object 'System.Windows.Forms.RowStyle' ('Absolute', 20)
	[void]$tlp1.RowStyles.Add($System_Windows_Forms_RowStyle_5)
	$tlp1.Size = '989, 323'
	$tlp1.TabIndex = 8
	#
	# panel1
	#
	$panel1.Controls.Add($btnApply)
	$panel1.Controls.Add($btnMerge)
	$panel1.Controls.Add($btnU1toU2)
	$panel1.Controls.Add($btnU2toU1)
	$panel1.BackColor = 'Control'
	$panel1.Dock = 'Fill'
	$panel1.Location = '452, 3'
	$panel1.Name = "panel1"
	$panel1.Size = '84, 317'
	$panel1.TabIndex = 8
	#
	# btnApply
	#
	$btnApply.Location = '4, 173'
	$btnApply.Name = "btnApply"
	$btnApply.Size = '75, 26'
	$btnApply.TabIndex = 4
	$btnApply.Text = "Apply"
	$btnApply.UseVisualStyleBackColor = $True
	$btnApply.add_Click($btnApply_Click)
	#
	# btnMerge
	#
	$btnMerge.Location = '4, 77'
	$btnMerge.Name = "btnMerge"
	$btnMerge.Size = '75, 26'
	$btnMerge.TabIndex = 7
	$btnMerge.Text = "Merge"
	$btnMerge.UseVisualStyleBackColor = $True
	$btnMerge.add_Click($btnMerge_Click)
	#
	# btnU1toU2
	#
	$btnU1toU2.Location = '4, 141'
	$btnU1toU2.Name = "btnU1toU2"
	$btnU1toU2.Size = '75, 26'
	$btnU1toU2.TabIndex = 2
	$btnU1toU2.Text = "---->"
	$btnU1toU2.UseVisualStyleBackColor = $True
	$btnU1toU2.add_Click($btnU1toU2_Click)
	#
	# btnU2toU1
	#
	$btnU2toU1.Location = '4, 109'
	$btnU2toU1.Name = "btnU2toU1"
	$btnU2toU1.Size = '75, 26'
	$btnU2toU1.TabIndex = 3
	$btnU2toU1.Text = "<-----"
	$btnU2toU1.UseVisualStyleBackColor = $True
	$btnU2toU1.add_Click($btnU2toU1_Click)
	#
	# GBUser2
	#
	$GBUser2.Controls.Add($lblU2)
	$GBUser2.Controls.Add($btnClearU2)
	$GBUser2.Controls.Add($LVU2)
	$GBUser2.Controls.Add($btnSelectAllU2)
	$GBUser2.Controls.Add($btnGetU2)
	$GBUser2.Controls.Add($txtbxSAM2)
	$GBUser2.Controls.Add($lblU2ADLogon)
	$GBUser2.BackColor = 'LightSlateGray'
	$GBUser2.Dock = 'Fill'
	$GBUser2.Font = "Microsoft Sans Serif, 8.25pt, style=Bold"
	$GBUser2.ForeColor = 'White'
	$GBUser2.Location = '542, 3'
	$GBUser2.Name = "GBUser2"
	$GBUser2.Size = '444, 317'
	$GBUser2.TabIndex = 0
	$GBUser2.TabStop = $False
	$GBUser2.Text = " User 2 "
	#
	# lblU2
	#
	$lblU2.Font = "Microsoft Sans Serif, 8.25pt"
	$lblU2.Location = '6, 32'
	$lblU2.Name = "lblU2"
	$lblU2.Size = '432, 23'
	$lblU2.TabIndex = 57
	$lblU2.TextAlign = 'MiddleLeft'
	#
	# btnClearU2
	#
	$btnClearU2.Font = "Microsoft Sans Serif, 8.25pt"
	$btnClearU2.ForeColor = 'Black'
	$btnClearU2.Location = '354, 10'
	$btnClearU2.Name = "btnClearU2"
	$btnClearU2.Size = '75, 23'
	$btnClearU2.TabIndex = 7
	$btnClearU2.Text = "Clear"
	$btnClearU2.UseVisualStyleBackColor = $True
	$btnClearU2.add_Click($btnClearU2_Click)
	#
	# LVU2
	#
	$LVU2.Anchor = 'Top, Bottom, Left, Right'
	[void]$LVU2.Columns.Add($LV1GroupName)
	[void]$LVU2.Columns.Add($LV1Type)
	[void]$LVU2.Columns.Add($LV1DN)
	$LVU2.Font = "Microsoft Sans Serif, 8.25pt"
	$LVU2.FullRowSelect = $True
	$LVU2.Location = '6, 55'
	$LVU2.Name = "LVU2"
	$LVU2.Size = '432, 256'
	$LVU2.TabIndex = 50
	$LVU2.UseCompatibleStateImageBehavior = $False
	$LVU2.View = 'Details'
	$LVU2.add_ColumnClick($LVU2_ColumnClick)
	#
	# btnSelectAllU2
	#
	$btnSelectAllU2.Font = "Microsoft Sans Serif, 8.25pt"
	$btnSelectAllU2.ForeColor = 'Black'
	$btnSelectAllU2.Location = '269, 10'
	$btnSelectAllU2.Name = "btnSelectAllU2"
	$btnSelectAllU2.Size = '83, 23'
	$btnSelectAllU2.TabIndex = 49
	$btnSelectAllU2.Text = "Select All"
	$btnSelectAllU2.UseVisualStyleBackColor = $True
	$btnSelectAllU2.add_Click($btnSelectAllU2_Click)
	#
	# btnGetU2
	#
	$btnGetU2.Font = "Microsoft Sans Serif, 8.25pt"
	$btnGetU2.ForeColor = 'Black'
	$btnGetU2.Location = '184, 10'
	$btnGetU2.Name = "btnGetU2"
	$btnGetU2.Size = '83, 23'
	$btnGetU2.TabIndex = 48
	$btnGetU2.Text = "Get"
	$btnGetU2.UseVisualStyleBackColor = $True
	$btnGetU2.add_Click($btnGetU2_Click)
	#
	# txtbxSAM2
	#
	$txtbxSAM2.Location = '70, 12'
	$txtbxSAM2.Name = "txtbxSAM2"
	$txtbxSAM2.Size = '111, 20'
	$txtbxSAM2.TabIndex = 48
	#
	# lblU2ADLogon
	#
	$lblU2ADLogon.AutoSize = $True
	$lblU2ADLogon.Font = "Microsoft Sans Serif, 8.25pt"
	$lblU2ADLogon.Location = '12, 16'
	$lblU2ADLogon.Name = "lblU2ADLogon"
	$lblU2ADLogon.Size = '58, 13'
	$lblU2ADLogon.TabIndex = 48
	$lblU2ADLogon.Text = "AD Logon:"
	#
	# GBUser1
	#
	$GBUser1.Controls.Add($lblU1)
	$GBUser1.Controls.Add($LVU1)
	$GBUser1.Controls.Add($btnClearU1)
	$GBUser1.Controls.Add($btnSelectAllU1)
	$GBUser1.Controls.Add($btnGetU1)
	$GBUser1.Controls.Add($txtbxSAM1)
	$GBUser1.Controls.Add($lblU1ADLogon)
	$GBUser1.BackColor = 'LightSlateGray'
	$GBUser1.Dock = 'Fill'
	$GBUser1.Font = "Microsoft Sans Serif, 8.25pt, style=Bold"
	$GBUser1.ForeColor = 'White'
	$GBUser1.Location = '3, 3'
	$GBUser1.Name = "GBUser1"
	$GBUser1.Size = '443, 317'
	$GBUser1.TabIndex = 1
	$GBUser1.TabStop = $False
	$GBUser1.Text = " User 1 "
	#
	# lblU1
	#
	$lblU1.Font = "Microsoft Sans Serif, 8.25pt"
	$lblU1.Location = '7, 32'
	$lblU1.Name = "lblU1"
	$lblU1.Size = '431, 23'
	$lblU1.TabIndex = 55
	$lblU1.TextAlign = 'MiddleLeft'
	#
	# LVU1
	#
	$LVU1.Anchor = 'Top, Bottom, Left, Right'
	[void]$LVU1.Columns.Add($LV2GroupName)
	[void]$LVU1.Columns.Add($LV2Type)
	[void]$LVU1.Columns.Add($LV2DN)
	$LVU1.Font = "Microsoft Sans Serif, 8.25pt"
	$LVU1.FullRowSelect = $True
	$LVU1.Location = '6, 55'
	$LVU1.Name = "LVU1"
	$LVU1.Size = '431, 256'
	$LVU1.TabIndex = 51
	$LVU1.UseCompatibleStateImageBehavior = $False
	$LVU1.View = 'Details'
	$LVU1.add_ColumnClick($LVU1_ColumnClick)
	#
	# btnClearU1
	#
	$btnClearU1.Font = "Microsoft Sans Serif, 8.25pt"
	$btnClearU1.ForeColor = 'Black'
	$btnClearU1.Location = '354, 10'
	$btnClearU1.Name = "btnClearU1"
	$btnClearU1.Size = '75, 23'
	$btnClearU1.TabIndex = 5
	$btnClearU1.Text = "Clear"
	$btnClearU1.UseVisualStyleBackColor = $True
	$btnClearU1.add_Click($btnClearU1_Click)
	#
	# btnSelectAllU1
	#
	$btnSelectAllU1.Font = "Microsoft Sans Serif, 8.25pt"
	$btnSelectAllU1.ForeColor = 'Black'
	$btnSelectAllU1.Location = '269, 10'
	$btnSelectAllU1.Name = "btnSelectAllU1"
	$btnSelectAllU1.Size = '83, 23'
	$btnSelectAllU1.TabIndex = 54
	$btnSelectAllU1.Text = "Select All"
	$btnSelectAllU1.UseVisualStyleBackColor = $True
	$btnSelectAllU1.add_Click($btnSelectAllU1_Click)
	#
	# btnGetU1
	#
	$btnGetU1.Font = "Microsoft Sans Serif, 8.25pt"
	$btnGetU1.ForeColor = 'Black'
	$btnGetU1.Location = '184, 10'
	$btnGetU1.Name = "btnGetU1"
	$btnGetU1.Size = '83, 23'
	$btnGetU1.TabIndex = 51
	$btnGetU1.Text = "Get"
	$btnGetU1.UseVisualStyleBackColor = $True
	$btnGetU1.add_Click($btnGetU1_Click)
	#
	# txtbxSAM1
	#
	$txtbxSAM1.Location = '70, 12'
	$txtbxSAM1.Name = "txtbxSAM1"
	$txtbxSAM1.Size = '111, 20'
	$txtbxSAM1.TabIndex = 52
	#
	# lblU1ADLogon
	#
	$lblU1ADLogon.AutoSize = $True
	$lblU1ADLogon.Font = "Microsoft Sans Serif, 8.25pt"
	$lblU1ADLogon.Location = '12, 16'
	$lblU1ADLogon.Name = "lblU1ADLogon"
	$lblU1ADLogon.Size = '58, 13'
	$lblU1ADLogon.TabIndex = 53
	$lblU1ADLogon.Text = "AD Logon:"
	#
	# btnClose
	#
	$btnClose.Anchor = 'Bottom, Right'
	$btnClose.DialogResult = 'OK'
	$btnClose.Location = '931, 360'
	$btnClose.Name = "btnClose"
	$btnClose.Size = '75, 23'
	$btnClose.TabIndex = 59
	$btnClose.Text = "Close"
	$btnClose.UseVisualStyleBackColor = $True
	#
	# LV1GroupName
	#
	$LV1GroupName.Text = "Group Name"
	$LV1GroupName.Width = 199
	#
	# Name
	#
	$Name.DisplayIndex = 0
	$Name.Text = "LV1Name"
	#
	# LV1Type
	#
	$LV1Type.Text = "Type"
	$LV1Type.Width = 100
	#
	# LV1DN
	#
	$LV1DN.Text = "Distinguished Name"
	$LV1DN.Width = 350
	#
	# LV2GroupName
	#
	$LV2GroupName.Text = "Group Name"
	$LV2GroupName.Width = 199
	#
	# LV2Type
	#
	$LV2Type.Text = "Type"
	$LV2Type.Width = 100
	#
	# LV2DN
	#
	$LV2DN.Text = "Distinguished Name"
	$LV2DN.Width = 350
	#endregion Generated Form Code

	#----------------------------------------------

	#Save the initial state of the form
	$InitialFormWindowState = $formSecurityGroupMirrorT.WindowState
	#Init the OnLoad event to correct the initial state of the form
	$formSecurityGroupMirrorT.add_Load($Form_StateCorrection_Load)
	#Clean up the control events
	$formSecurityGroupMirrorT.add_FormClosed($Form_Cleanup_FormClosed)
	#Store the control values when form is closing
	$formSecurityGroupMirrorT.add_Closing($Form_StoreValues_Closing)
	#Show the Form
	return $formSecurityGroupMirrorT.ShowDialog()

}
#endregion Source: SecurityGroupMirrorTool.pff

#Start the application
Main ($CommandLine)
